home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13105 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: eccdb1.pms.ford.com!pms991!mbobak
  2. From: mbobak@pms991.uucp (Mark J. Bobak)
  3. Newsgroups: comp.unix.programmer,comp.lang.c
  4. Subject: Re: getpwnam() -error checking
  5. Date: 4 Apr 1996 17:45:19 GMT
  6. Organization: Not an Official Spokesperson for Ford Motor Company, Dearborn, MI
  7. Message-ID: <4k11rf$lav@eccdb1.pms.ford.com>
  8. References: <Pine.SOL.3.91.960327025242.5526B-100000@ee.tamu.edu>
  9. NNTP-Posting-Host: pms991.pms.ford.com
  10.  
  11. In article <Pine.SOL.3.91.960327025242.5526B-100000@ee.tamu.edu>,
  12. Ajay Kumar Gummadi  <ajay@ee.tamu.edu> wrote:
  13. >
  14. >Hi all,
  15. >
  16. >  The function getpwnam() takes the user-id as input argument and returns 
  17. >a pointer to a structure, that contains all the user information.
  18. >
  19. >  If I give a wrong /non-existent user-id as input argument, how can I 
  20. >check the error condition that may arise, before, the system dumps core.
  21. >
  22. >  Reply by email will be very helpful.
  23.  
  24. getpwnam() will return a pointer to a struct passwd on success or a NULL
  25. on failure.  So, just check to see if you were passed a NULL.  If you were,
  26. then the user id probably doesn't exist.  (I say probably doesn't exist because
  27. there may be other error conditions that would cause getpwnam() to return NULL.)
  28.  
  29. You'd be better off asking this in comp.unix.programmer.
  30.  
  31. -Mark
  32. -- 
  33. Mark J. Bobak, Application Developer
  34. Advanced Vehicle & Computer Aided Engineering Systems Department
  35. Process Leadership, Ford Motor Company
  36. mbobak@ford.com
  37.